#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/10/7 14:25
# @Author  : Crissu
# @Site    : 
# @File    : changeSuffix.py
# @Software: PyCharm
import os
import multiprocessing
from configs import changeSuffix_config

def changeFileSuffix():
    classList = os.listdir(changeSuffix_config.FromPath)
    print(classList)

    pool = multiprocessing.Pool(processes=16)
    pool.map_async(doChangeFileSuffix, classList)
    pool.close()
    pool.join()


def doChangeFileSuffix(className):
    fromPath = changeSuffix_config.FromPath + className + "/"
    namesList = os.listdir(fromPath)
    for name in namesList:
        portion = os.path.splitext(name)
        if portion[1] != ".jpg":
            newName = portion[0] + ".jpg"
            rawPath = fromPath + name
            newPath = changeSuffix_config.ToPath + className + "/" + newName
            os.rename(rawPath, newPath)
            print("修改成功")














